<extend name="common:commonTemplate" />
<block name="main_content">
<div id="content">
	<div id="content-header">
		<div id="breadcrumb">
			<a class="tip-bottom" href="index.html"
				data-original-title="Go to Home"><i class="icon-home"></i> 首页</a> <a
				href="#">推广人</a> <a class="current" href="#">推广人信息列表</a>
		</div>

	</div>
	<div class="container-fluid">
		<div class="row-fluid">
			<div class="span6">
				<div class="widget-box">
					<div class="widget-title">
						<span class="icon"> <i class="icon-info-sign"></i>
						</span>
						<h5>推广人信息</h5>
						<span style="float:right;margin:3px;"><a id="btn_resetPwd" class="btn btn-primary" href="javascript:void(0);">重置密码</a></span>
					</div>
					<div class="widget-content nopadding">
						<form novalidate="novalidate" id="basic_validate"
							name="basic_validate" action="#" method="post"
							class="form-horizontal">
							<div class="control-group">
								<label class="control-label">推广人编号</label>
								<div class="controls">
									<input type="text" id="promoter_id"
										value="{$promoter_en.promoter_id}" name="required"
										readonly="true" />
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">手机</label>
								<div class="controls">
									<input type="text" value="{$promoter_en.cellphone}"
										id="cellphone" name="required">
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">姓名</label>
								<div class="controls">
									<input type="text" value="{$promoter_en.real_name}"
										id="promoter_name" name="required">
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">推广人类型</label>
								<div class="controls">
									<if condition="$promoter_en.promoter_type eq 1"> <span
										style="margin-right: 15px;"><input id="radPerson"
										checked="checked" type="radio" name="radPromoterType"
										value="1" /> 个人</span> <span><input id="radAgency"
										type="radio" name="radPromoterType" value="2" /> 经销商</span> <else />
									<span style="margin-right: 15px;"><input id="radPerson"
										type="radio" name="radPromoterType" value="1" /> 个人</span> <span><input
										id="radAgency" checked="checked" type="radio"
										name="radPromoterType" value="2" /> 经销商</span> </if>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">性别</label>
								<div class="controls">
									<if condition="$promoter_en.sex eq 1"> <span
										style="margin-right: 15px;"><input id="radMan"
										checked="checked" type="radio" name="radSex" value="1" /> 男</span> <span><input
										id="radWoman" type="radio" name="radSex" value="2" /> 女</span> 
									<else />
									<span style="margin-right: 15px;"><input id="radMan"
										type="radio" name="radSex" value="1" /> 男</span> <span><input
										id="radWoman" checked="checked" type="radio" name="radSex"
										value="2" /> 女</span>
									</if>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">身份证号码</label>
								<div class="controls">
									<input type="text" value="{$promoter_en.id_card_no}"
										id="id_card_no" name="required">
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">营业执照号码</label>
								<div class="controls">
									<input type="text" value="{$promoter_en.business_license_no}"
										id="business_license_no" name="required">
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">支付宝账户</label>
								<div class="controls">
									<input type="text" readonly="true"
										value="{$promoter_en.alipay_id}" id="alipay_id"
										name="required">
									<code>（仅限用户本人修改）</code>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">余额</label>
								<div class="controls">
									<input type="text" readonly="true"
										value="{$promoter_en.amount}" id="amount" name="required">
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">可提现余额</label>
								<div class="controls">
									<input type="text" readonly="true"
										value="{$promoter_en.withdraw_amount}" id="withdraw_amount"
										name="required">
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">推广人状态</label>
								<div class="controls">
									<span id="promoter_status" style="color:red;">{$promoter_en.status_text}</span> 
									<input type="hidden" id="status_text" value="{$promoter_en.status_text}">
									<span style="margin-left:25px;"></span>
									<a id="btn_statusPass" class="btn btn-success">审核通过</a> 
									<a id="btn_statusRefuse" class="btn btn-danger">审核拒绝</a>
								</div>
							</div>
							<div class="control-group" id="detailed"  style="display: none">
								<label class="control-label">拒绝原因</label>
								<div class="controls">
									<input type="text" style="width:180px;" id="reject_reason"/>(*必填)<a id="btn_confirm_reject" class="btn btn-danger">确认拒绝</a>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">身份证</label>
								<div class="controls">
									<volist id="id_card_image" name="promoter_en.id_card_image_list">
									<a target="_blank" href="{$id_card_image}"><img width="200px;" src="{$id_card_image}" /></a>
									</volist>
								</div>
							</div>
							
							<if condition="$promoter_en.promoter_type eq 2 ">
							<div class="control-group">
								<label class="control-label">营业执照</label>
								<div class="controls">
									<a target="_blank" href="{$promoter_en.business_license_image}">
										<img width="200px;" src="{$promoter_en.business_license_image}" />
									</a>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">组织机构证</label>
								<div class="controls">
									<a target="_blank" href="{$promoter_en.organization_image}">
										<img width="200px;" src="{$promoter_en.organization_image}" />
									</a>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">税务登记证</label>
								<div class="controls">
									<a target="_blank" href="{$promoter_en.tax_registration_image}">
										<img width="200px;" src="{$promoter_en.tax_registration_image}" />
									</a>
								</div>
							</div>
							</if>
							
							
							<div class="form-actions">
								
							</div>
						</form>
					</div>
				</div>
			</div>
			
			<div class="span6">
				<div class="widget-box">
					<div class="widget-title">
						<span class="icon"> <i class="icon-th"></i>
						</span>
						<h5>
							<span style="color: red">{$promoter_en.real_name}</span> 推广订单列表
						</h5>
						<span style="float:right;margin:3px;"><a href="/Promoter/amountList?promoter_id={$promoter_en.promoter_id}" class="btn btn-primary">查看余额列表</a></span>
					</div>
					<div class="widget-content nopadding">
						<table id="search_result" class="table table-bordered table-striped">
							<thead>
								<tr>
									<th>订单编号</th>
									<th>订单时间</th>
									<th>订单金额</th>
									<th>分成金额</th>
									<th>订单状态</th>
									<th>分成状态</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody>
								
							</tbody>
						</table>
					</div>
				</div>
				<div id="paging"
					class="fg-toolbar ui-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix">
					<div
						class="dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi ui-buttonset-multi paging_full_numbers"
						id="DataTables_Table_0_paginate">
						<a page_index="1"
							class="first ui-corner-tl ui-corner-bl fg-button ui-button ui-state-default"
							tabindex="0" id="DataTables_Table_0_first">首页</a> <a
							class="previous fg-button ui-button ui-state-default"
							tabindex="0" id="DataTables_Table_0_previous">上页</a> <span>共<span
							id="total_count">0</span>条 <span id="curr_page_index">0</span>/<span
							id="total_page">0</span></span> <a
							class="next fg-button ui-button ui-state-default" tabindex="0"
							id="DataTables_Table_0_next">下页</a> <a
							class="last ui-corner-tr ui-corner-br fg-button ui-button ui-state-default"
							tabindex="0" id="DataTables_Table_0_last">末页</a> <span> <span><input
								type="text" style="width: 20px;" class="ui-state-default"></span>

							<a class="fg-button ui-button ui-state-default" tabindex="0">跳转</a>
						</span>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

</block>

<block name="js_content"> <script>
	PromoterDetailPage = {
		'Search': function(page_index){
			var cellphone		= '';
			var promoter_id		= $('#promoter_id').val();
			var promoter_name	= '';
			var order_id		= '';
			var page_size		= ServerConfig.OrderConfig.promoterDetailPage_search_default_size;

			var result = OrderService.SearchOrderList(promoter_id, promoter_name, order_id,
					'','','',
					'','',
				page_index, page_size);

			if(result.IsSuccess == 0){
				alert(result.ErrorMsg);
				return;
			}
			else{
				//lst_promoter_en, total_page, total_count, page_index
				PromoterDetailPage.FillTable(result.Result.lst_order_en, page_index);
				PromoterDetailPage.SetPageIndex(result.Result.total_page, result.Result.total_count, page_index);
			}
		},
		'FillTable': function(lst_order_en, page_index){
			var html_array = new Array();
			for(var index in lst_order_en){
				var order_en = lst_order_en[index];
				html_array.push('<tr class="odd gradeX">');
				
				html_array.push('<td>' + order_en.order_id + '</td>');
				html_array.push('<td>' + order_en.order_date + '</td>');
				html_array.push('<td>' + order_en.order_amount + '</td>');
				html_array.push('<td>' + order_en.revenue_amount + '</td>');
				html_array.push('<td>' + order_en.order_status_text + '</td>');
				html_array.push('<td>' + order_en.order_revenue_status_text + '</td>');
				
				
				html_array.push('<td><div style="text-align:center;"><a target="_blank" style="color:blue;" href="' + ServerConfig.UrlConfig.order_whaleyinfo_site + 'order/orderdetail?order_id=' + order_en.order_id + '">订单明细</a>&nbsp;&nbsp;&nbsp;&nbsp;');
				html_array.push('<a style="color:blue;" href="/order/detail?order_id=' + order_en.order_id + '">推广订单详情</a></div></td>');
				html_array.push('</tr>');
			}
			
			var html = html_array.join('\r\n');
			$('#search_result tbody').html('');
			$('#search_result tbody').html(html);
			
			$('#search_result').attr('page_index', page_index);;
		},
		'SetPageIndex': function(total_page, total_count, page_index){
			$('#total_count').text(total_count);
			$('#total_page').text(total_page);
			$('#curr_page_index').text(page_index);
			page_index = parseInt(page_index);
			
			
			
			if(page_index == 1){
				$('#paging .first').addClass('ui-state-disabled');
				$('#paging .previous').addClass('ui-state-disabled');
				$('#paging .first').attr('page_index', 1);
				$('#paging .previous').attr('page_index', 1);
			}
			else{
				$('#paging .first').removeClass('ui-state-disabled');
				$('#paging .previous').removeClass('ui-state-disabled');
				$('#paging .first').attr('page_index', 1);
				$('#paging .previous').attr('page_index', page_index - 1);
			}
	
			if(total_page == page_index){
				$('#paging .last').addClass('ui-state-disabled');
				$('#paging .next').addClass('ui-state-disabled');
				$('#paging .last').attr('page_index', total_page);
				$('#paging .next').attr('page_index', total_page);
			}
			else{
				$('#paging .last').removeClass('ui-state-disabled');
				$('#paging .next').removeClass('ui-state-disabled');
				$('#paging .last').attr('page_index', total_page);
				$('#paging .next').attr('page_index', page_index + 1);
			}
		},
		'ConfirmReject': function(){
			var reject_reason = $('#reject_reason').val();
			if(reject_reason == ''){
				alert('拒绝原因必填');
				return;
			}
			var promoter_id = $('#promoter_id').val();
			var reject_reason = $('#reject_reason').val();
			var result = PromoterService.UpdatePromoterStatus(promoter_id, 2,reject_reason);
			if (result.IsSuccess == 0) {
				alert(result.ErrorMsg);
				return;
			} else {
				alert('操作成功');
				$('#promoter_status').text('审核拒绝');
			}
		},
		'BindEvent' : function() {
			$('#btn_update').bind('click', function() {
				alert('后台暂不能修改客户信息，仅能重置密码');
			});
			
			//审核通过按钮
			$('#btn_statusPass').bind('click', function(){
				var promoter_id = $('#promoter_id').val();
				
				var result = PromoterService.UpdatePromoterStatus(promoter_id, 1);

				if (result.IsSuccess == 0) {
					alert(result.ErrorMsg);
					return;
				} else {
					alert('操作成功');
					$('#promoter_status').text('有效');
				}
			});
			
			//审核拒绝按钮
			$('#btn_statusRefuse').bind('click', function(){
				$("#detailed").css({display:"block"});
			});
			
			//拒绝事件
			$('#btn_confirm_reject').bind('click', function(){
				PromoterDetailPage.ConfirmReject();
			});
			
			
			$('#btn_resetPwd').bind('click', function() {
  
				if (confirm("确定要重置该用户密码么？")) {
					var promoter_id = $('#promoter_id').val();
					var result = PromoterService.ResetPwd(promoter_id);

					if (result.IsSuccess == 0) {
						alert(result.ErrorMsg);
						return;
					} else {
						alert('已将该用户的密码重置为：123456');
					}
				}
			});
			
			
			$(".first,.previous,.last,.next").bind('click', function(){
				if($(this).hasClass('ui-state-disabled')){
					return false;
				}
				
				var page_index = $(this).attr('page_index');
				if(page_index == undefined){
					page_index = 1;
				}
				
				PromoterDetailPage.Search(page_index);
			});
		},

	};

	$(document).ready(function() {
		
		PromoterDetailPage.BindEvent();
		PromoterDetailPage.Search(1);

	});
</script> </block>